﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;

public class RankingListManager : MonoBehaviour
{
    public Text[] RankingList;
    public int RankingListNumber = 10;

    private string GetRankingListMember(int n)
    {
        string tmp = PlayerPrefs.GetString("@MaxName" + n.ToString());
        while (tmp.Length < 10)
        {
            tmp += " ";
        }
        return tmp +"\t\t\t\t\t"+ PlayerPrefs.GetInt("@MaxScore" + n).ToString();
    }

    void Awake()
    {
        for (int i = 0; i < RankingListNumber; i++)
        {
            if (PlayerPrefs.GetInt("@MaxScore" + i.ToString()) <= 0)
            {
                RankingList[i].text = "暂无玩家\t\t\t\t\t暂无成绩";
            }
            else
            {
                RankingList[i].text = GetRankingListMember(i);
            }
        }
    }

    public void BackMain()
    {
        SceneManager.LoadScene(1);
    }
}
